package com.itstherules.jmsunit.expectation.xml.xpath;

import java.io.IOException;

import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.exceptions.XpathException;
import org.xml.sax.SAXException;

import com.itstherules.jmsunit.expectation.StringExpectation;

public abstract class BaseXPathExpectation implements StringExpectation {

	public final void compute(String actualXml) throws AssertionError {
		XMLUnit.setIgnoreWhitespace(true);
		try {
			computeSpecific(actualXml);
		} 
		catch (XpathException e) { throw new IllegalArgumentException(e);}
		catch (SAXException e) { throw new AssertionError(e);}
		catch (IOException e) { throw new IllegalArgumentException(e);}
	}

	protected abstract void computeSpecific(String actualXml) throws XpathException, SAXException, IOException;

}
